home *** CD-ROM | disk | FTP | other *** search
- Path: newsfeed.direct.ca!usenet
- From: etoivane@direct.ca (Ed Toivanen)
- Newsgroups: comp.lang.c
- Subject: gets(rec->num); I don't know what I am doing wrong...
- Date: 9 Feb 1996 05:41:17 GMT
- Organization: Your Organization
- Message-ID: <4fempt$mjg@aphex.direct.ca>
- NNTP-Posting-Host: 204.174.244.95
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-Newsreader: WinVN 0.99.6
-
- I posted the code that I wrote so far. I can't make gets(rec->id); work
- properly, I get 6 or 7 compilation errors indicating that parameter 1 does not
- match function prototype. Each gets() call is incorrect! What to do?
- /*
- Ed Toivanen
- Assign2
- Comp 3425(Wed)
- Feb 5, 1996
- */
- #define NAME_LEN 40
-
- typedef enum {FALSE, TRUE} bool;
-
- typedef enum {SCIENCE, ART} PROGRAM;
-
- typedef struct science_mark {
- int math, physics, compsci; /* Range: 0..100 */
- }SCIENCE_MARK;
-
- typedef struct art_mark {
- int acting, dancing; /* Range: 0..100 */
- }ART_MARK;
-
- typedef union mark {
- SCIENCE_MARK scientist;
- ART_MARK artist;
- }MARK;
-
- typedef struct student_record{
- int id; /* Range: 1..99, Unique */
- char name[NAME_LEN + 1]; /* Non-unique */
- PROGRAM major;
- MARK marks;
- } STUDENT_RECORD;
-
-
- /*
- Assign2.c
- */
-
- #include<stdio.h>
- #include"assign2.h"
-
- bool initList(char*, FILE*);
- bool addRecord(FILE*, STUDENT_RECORD*);
- bool deleteRecord(FILE*, STUDENT_RECORD*);
- bool searchforRecord(FILE*, STUDENT_RECORD*);
- bool printList(FILE*);
- bool printRecord(FILE*, STUDENT_RECORD*);
-
- int main(void){
- char studentList[8 + 1];
- FILE * filePtr;
-
- printf("Enter database file to open\n");
- while(!gets(studentList))
- {}
-
- if(!initList(studentList, filePtr)){
- return(1);
- }
-
- return(0);
- }
-
- bool initList(char* list, FILE* fp){
- if(!(fp = fopen(list, "wb"))){
- printf("Error opening %s\n", list);
- fclose(fp);
- return(FALSE);
- }
- else
- return(TRUE);
- }
-
- bool addRecord(FILE* fp, STUDENT_RECORD* rec){
- printf("Student id\n");
- gets(rec->id);
-
- printf("Student's last name first\n");
- gets(rec->name);
-
- printf("Major\n");
- gets(rec->major);
-
- printf("Grades\n");
- switch(rec->major){
- case SCIENCE:
- printf("Math\n");
- fprintf(fp, gets(rec->marks.scientist.math));
-
- printf("Physics\n");
- fprintf(fp, gets(rec->marks.scientist.physics));
-
- printf("Compsci\n");
- fprintf(fp, gets(rec->marks.scientist.compsci));
- break;
- case ART:
- printf("Acting\n");
- fprintf(fp, gets(rec->marks.artist.acting));
-
- printf("Dancing\n");
- fprintf(fp, gets(rec->marks.artist.dancing));
- break;
- default :
- break;
- }
- return(TRUE);
- }/*End addRec*/
-
-